import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../../lib_baseview/theme/jr.dart';
import '../../../../lib_baseview/utils/constant/text_styles.dart';
import '../../../../resource/language/generated/l10n.dart';

class UserListKickItemWidget extends StatelessWidget {
  final int index;
  final int rid;
  // final RoomKickListItem item;
  final VoidCallback? onUnset;

  const UserListKickItemWidget({
    super.key,
    required this.rid,
    required this.index,
    // required this.item,
    this.onUnset,
  });

  Future<void> onButtonTap() async {
    // var dialogResult = await JRDialog.showCommonDialog(
    //     context: Get.context!,
    //     data: TextWithHorizontalBtnDialogData(
    //         title: T.current!.lift_kick_people,
    //         desc: T.current!.allow_user_enter_room));
    // if (dialogResult != true) return;

    // var result = await handleRsp(() => Api.unkick(rid, item.id.toInt()));
    // if (result.isSuccess) onUnset?.call();
  }

  Widget get button {
    return GestureDetector(
      onTap: onButtonTap,
      child: Container(
        width: 72,
        height: 28,
        alignment: Alignment.center,
        decoration:
            ShapeDecoration(color: JR.color.mainBrand, shape: StadiumBorder()),
        child: Text(
          T.current!.lift_kick,
          style: JRTextStyles.styleFont12W400.copyWith(color: Colors.black),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Ink(
        height: 80.h,
        child: InkWell(
          onTap: () {
            // if (item.id.toInt() <= 0) return;
            // SimpleChannelUser userModel = SimpleChannelUser.create()
            //   ..id = item.id
            //   ..nickname = item.nickname
            //   ..avatar = item.avatar;
            // RoomPersonalDataWidget.show(
            //     Get.context!, RootProxyModel.instance?.channel, userModel);
          },
          child: Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              Container(
                width: 47,
                alignment: Alignment.center,
                child: _rankIndex,
              ),
              // AvatarImage(
              //     url: StringUtil.formatImgUrl(item.avatar, size: 150),
              //     width: 42,
              //     height: 42,
              //     shape: BoxShape.circle),
              const SizedBox(
                width: 12,
              ),
              Expanded(
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Text('nickname',
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: JRTextStyles.styleFont14W600
                                .copyWith(color: JR.color.mainText)),
                        const SizedBox(height: 6),
                        // SexAgeLabel(
                        //     isMale: item.gender == UserConstants.genderMan,
                        //     age: '${item.age.toInt()}')
                      ],
                    ),
                    const SizedBox(height: 5),
                    Text('ID:',
                        style: JRTextStyles.styleFont12W400
                            .copyWith(color: JR.color.secondaryText)),
                    const SizedBox(height: 5),
                    Text('desc',
                        style: JRTextStyles.styleFont12W400
                            .copyWith(color: JR.color.secondaryText)),
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 12),
                child: button,
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget get _rankIndex {
    return Text('${index + 1}',
        style: JRTextStyles.styleFont14W600.copyWith(
            color: JR.color.secondaryText, fontFamily: 'DINAlternate-bold'));
  }
}
